$(function() {
  $(':button#itemssnquery').bind('click', function() {
    $.getJSON('/_setitem', {
      pageid: $("#spanPageNum").text(),
      date: new Date().getTime()+Math.random()
    }, function(data) {
      var curr = data.items;
      var lang = data.lang;
      createTable(curr, lang);
    });
    return false;
  });
})

function createTable(tableList, flags)
{
  var s = '';
  s += "<table id='tbl_ls' border='1' cellspacing='0' cellpadding='0'>";
  s += "<thead>";
  s += "<tr>";
  if(flags == "zh_CN") {
    s += "<th>索引</th>";
    s += "<th>物料</th>";
    s += "<th>描述</th>";
    s += "<th>频段</th>";
    s += "<th>指标</th>";
    s += "<th>制程</th>";
    s += "<th>类型</th>";
    s += "<th>产品代码</th>";
    s += "<th>产品工厂代码</th>";
    s += "<th>包装数量</th>";
    s += "<th>是否锁定</th>";  
  } else {
    s += "<th>Index</th>";
    s += "<th>Item</th>";
    s += "<th>Description</th>";
    s += "<th>Band</th>";
    s += "<th>Limit</th>";
    s += "<th>Routing</th>";
    s += "<th>Type</th>";
    s += "<th>Code</th>";
    s += "<th>FacCode</th>";
    s += "<th>PackQty</th>";
    s += "<th>Lock</th>";
  }  
  s += "</tr>";
  s += "</thead>";
  s += "<tbody id='group_one'>";
  for(var idx in tableList)
  {
    if(idx%2 == 0)
    {
      s += "<tr class='alt-row'>";
    }
    else
    {
      s += "<tr class=''>"; 
    }
    s += "<td fieldset style='color: #666666; border-style: groove; font-weight: bold; font-size: 14px' align='center'>"+tableList[idx].Index+"</td>";
    s += "<td fieldset style='color: #666666; border-style: groove; font-weight: bold; font-size: 14px'>"+tableList[idx].Item+"</td>";
    s += "<td fieldset style='color: #666666; border-style: groove; font-weight: bold; font-size: 14px'>"+tableList[idx].Desc+"</td>";
    s += "<td fieldset style='color: #666666; border-style: groove; font-weight: bold; font-size: 14px'>"+tableList[idx].Band+"</td>";
    s += "<td fieldset style='color: #666666; border-style: groove; font-weight: bold; font-size: 14px'>"+tableList[idx].Limit+"</td>";
    s += "<td fieldset style='color: #666666; border-style: groove; font-weight: bold; font-size: 14px'><a href='/routing?q="+tableList[idx].Route+"'>"+tableList[idx].Route+"</a></td>";
    s += "<td fieldset style='color: #666666; border-style: groove; font-weight: bold; font-size: 14px' align='center'>"+tableList[idx].PrdType+"</td>";
    s += "<td fieldset style='color: #666666; border-style: groove; font-weight: bold; font-size: 14px' align='center'>"+tableList[idx].PrdCode+"</td>";
    s += "<td fieldset style='color: #666666; border-style: groove; font-weight: bold; font-size: 14px'>"+tableList[idx].FacCode+"</td>";
    s += "<td fieldset style='color: #666666; border-style: groove; font-weight: bold; font-size: 14px'>"+tableList[idx].PackQty+"</td>";
    s += "<td fieldset style='color: #666666; border-style: groove; font-weight: bold; font-size: 14px' align='center'>"+tableList[idx].Locked+"</td>";
    s += "</tr>";
  }
  s += "</tbody>";
  s += "</table>";
  obj1.innerHTML = s;
}

function pagequery()
{
  itemssnquery.click();
}